package org.come.lianhua;

import com.tool.btn.MoBanBtn;
import com.tool.time.Limit;
import com.tool.time.TimeLimit;
import come.tool.Fighting.FightingMixDeal;
import org.come.Frame.NewRefiningJframe;
import org.come.Frame.SuitBaptizeJframe;
import org.come.Frame.WorkshopRefiningJframe;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.ForgeJpanel;
import org.come.entity.Goodstable;
import org.come.summonequip.JframeSummonEquipMain;
import org.come.until.RefiningUtil;

import java.awt.*;
import java.awt.event.MouseEvent;

public class AotoMaticRefiningBtn extends MoBanBtn {
    private ForgeJpanel forgeJpanel;
    private AutoMaticRefiningJpanel autoMaticRefiningJpanel;
    private int caoz;


    public AotoMaticRefiningBtn(final String iconpath, final int type, final Color[] colors, final Font font, final String text, final AutoMaticRefiningJpanel autoMaticRefiningJpanel, int caoz) {
        super(iconpath, type, colors);
        this.autoMaticRefiningJpanel = autoMaticRefiningJpanel;
        this.setText(text);
        this.setFont(font);
        this.setVerticalTextPosition(0);
        this.setHorizontalTextPosition(0);
        this.caoz = caoz;
    }

    @Override
    public void chooseyes() {

    }

    @Override
    public void chooseno() {

    }

    @Override
    public void nochoose(final MouseEvent e) {

        Limit vip = TimeLimit.getLimits().getLimit("VIP");
        if(vip == null){
            ZhuFrame.getZhuJpanel().addPrompt("请先开通月卡功能#46");
            return;
        }
        if (caoz == 0) {
            autoMaticRefiningJpanel.getOptionJpanel().setVisible(!autoMaticRefiningJpanel.getOptionJpanel().isVisible());
        } else if (caoz == 1) {
            if ((autoMaticRefiningJpanel.getDisplaymodetext().getText().equals("炼化") ||
                    autoMaticRefiningJpanel.getDisplaymodetext().getText().equals("星卡神通")||
                    autoMaticRefiningJpanel.getDisplaymodetext().getText().equals("炼器")) &&
                    autoMaticRefiningJpanel.getStart().getText().equals("运行")) {
//                if(!NewRefiningJframe.getNewRefiningJframe().isVisible()){
//                    ZhuFrame.getZhuJpanel().addPrompt("请先打开炼化面板！#53");
//                    return;
//                }
                NewRefiningJframe.getNewRefiningJframe().getRefiningJpanel().getOperBtn3().nochoose(null);
                autoMaticRefiningJpanel.getStart().setText("停止");
                autoMaticRefiningJpanel.setCount(0);
            }else if(autoMaticRefiningJpanel.getDisplaymodetext().getText().equals("配饰重铸") &&  autoMaticRefiningJpanel.getStart().getText().equals("运行")){
                Goodstable[] goods = WorkshopRefiningJframe.getWorkshopRefiningJframe().getWorkshopRefiningJpanel().getCardJpanel().getEquiJpanel2().getGoods();
                String detection = RefiningUtil.detection(goods, 2);
                if(detection.equals("佩饰重铸")){
//                    WorkshopRefiningJframe.getWorkshopRefiningJframe().getWorkshopRefiningJpanel().getCardJpanel().getEquiJpanel().getWorkshopBtn().nochoose(null);
                    autoMaticRefiningJpanel.getStart().setText("停止");
                    autoMaticRefiningJpanel.petShidetectionProperties(null);
                    autoMaticRefiningJpanel.setCount(0);
                }else{
                    ZhuFrame.getZhuJpanel().addPrompt("请检查炼化材料#46");
                }
            }else if((autoMaticRefiningJpanel.getDisplaymodetext().getText().equals("兽装重悟技能") || autoMaticRefiningJpanel.getDisplaymodetext().getText().equals("兽装重洗属性"))&&  autoMaticRefiningJpanel.getStart().getText().equals("运行")){
                autoMaticRefiningJpanel.getStart().setText("停止");
                JframeSummonEquipMain.getJframeSummonEquipMain().getJpanelSummonEquipMain().getAckBtn().nochoose(null);
                autoMaticRefiningJpanel.setCount(0);
            }else if(autoMaticRefiningJpanel.getDisplaymodetext().getText().equals("套装洗炼") && autoMaticRefiningJpanel.getStart().getText().equals("运行")){
                SuitBaptizeJframe.getSuitBaptizeJframe().getBaptizeJpanel().getBaptizeBtn1().nochoose(null);
                autoMaticRefiningJpanel.getStart().setText("停止");
            }else if(autoMaticRefiningJpanel.getStart().getText().equals("停止")){
                autoMaticRefiningJpanel.setCount(0);
                autoMaticRefiningJpanel.getStart().setText("运行");
            }


        }
    }

}
